﻿function CDropDownCheckList(opts) {
    var self = this;
    this.options = {

    };
    $.extend(true, self.options, opts);
    this.container = "";
    var fn_Extend = function (container) {
        container = container || self.container;
        if (container && $(container).length) {
            var size = $(container).size();
            $.each($(container), function (index, item) {
                var id = $.string.Format("#ddcl-{0}-ddw", $(item).attr("id"));
                if ($(id).length) {
                    $(id).append("<div class='ddcl-icon-close'><span class='ui-icon ui-icon-close'></span><span class='ddcl-text-close'>Đóng</span></div>");
                }
            });

        }
    };
    this.Init = function (container) {
        self.container = container;
        $(container).dropdownchecklist(self.options);
        fn_Extend();
    };
    this.GetValue = function () {
        return $(self.container).val();
    };
    this.Refresh = function () {
        $(self.container).dropdownchecklist("refresh");
    };
    this.Clear = function () {
        self.Destroy();
        $(self.container).find("option").removeAttr("selected");
        self.Init(self.container);
    };
    this.Destroy = function () {
        $(self.container).dropdownchecklist("destroy");
    };
}